/*
 * @Author: szx
 * @Date: 2021-10-19 13:31:30
 * @LastEditTime: 2021-10-19 13:57:48
 * @Description:
 * @FilePath: \leetcode\211\211_2.go
 */

package main

type WordDictionary struct {
	data map[int][]string
}

func Constructor() WordDictionary {
	return WordDictionary{make(map[int][]string)}
}

func (this *WordDictionary) AddWord(word string) {
	l := len(word)
	if list, ok := this.data[l]; ok {
		this.data[l] = append(list, word)
	} else {
		this.data[l] = []string{word}
	}
}

func (this *WordDictionary) Search(word string) bool {
	l := len(word)
	if list, ok := this.data[l]; ok {
		for _, d := range list {
			flag := true
			for i, w := range word {
				if w == '.' {
					continue
				}
				if string(d[i]) != string(w) {
					flag = false
					break
				}
			}
			if flag {
				return true
			}
		}
	}
	return false
}

func main() {
	for i := 0; i < 10; i++ {
		for j := 20; j < 30; j++ {
			println(j)
			if j == 24 {
				continue
			}
		}
	}
}

/**
 * Your WordDictionary object will be instantiated and called as such:
 * obj := Constructor();
 * obj.AddWord(word);
 * param_2 := obj.Search(word);
 */
